//
// ADC handling for Potentiometers
//
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/debug.h"
#include "driverlib/sysctl.h"
#include "driverlib/adc.h"



#ifdef DEBUG
void__error__(char *pcFilename, unsigned long ulLine)
{
}
#endif

// ADC will use the same timer as buttonPress (Timer0A)
// So make sure ADCConfig() called after ButtonConfig()
// in main.

void ADCConfig(void){
	unsigned long ulADC0Value[4];
	volatile unsigned long ulTempAvg;
	volatile unsigned long ulTempValueC;
	volatile unsigned long ulTempValueF;

	SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
//	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); // Already enabled before this function call
	SysCtlADCSpeedSet(SYSCTL_ADCSPEED_250KSPS);

	// Disable ADCSequence before modifying values
	ADCSequenceDisable(ADC0_BASE, 1);

	ADCSequenceConfigure(ADC0_BASE, 1, ADC_TRIGGER_PROCESSOR, 0);
	ADCSequenceStepConfigure(ADC0_BASE, 1, 0, ADC_CTL_TS);
	ADCSequenceStepConfigure(ADC0_BASE, 1, 1, ADC_CTL_TS);
	ADCSequenceStepConfigure(ADC0_BASE, 1, 2, ADC_CTL_TS);
	ADCSequenceStepConfigure(ADC0_BASE, 1, 3, ADC_CTL_TS | ADC_CTL_IE | ADC_CTL_END);

	ADCSequenceEnable(ADC0_BASE, 1);


}
